package com.heihei.controller.son;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heihei.common.page.Query;
import com.heihei.common.response.ResponseVO;
import com.heihei.entity.son.SonSingerEntity;
import com.heihei.service.son.SonSingerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 歌手表 前端控制器
 * </p>
 *
 * @author duanhengfei
 * @since 2021-11-29
 */
@Api(tags = "歌手 Controller")
@RestController
@RequestMapping("/son/singer")
public class SonSingerController {
    @Resource
    private SonSingerService sonSingerService;

    @ApiOperation(value = "添加")
    @PostMapping("/add")
    public ResponseVO<String> add(@RequestBody SonSingerEntity paramEntity) {
        return this.sonSingerService.myAdd(paramEntity);
    }

    @ApiOperation(value = "修改")
    @PatchMapping("/update")
    public ResponseVO<Boolean> update(@RequestBody SonSingerEntity paramEntity) {
        return this.sonSingerService.myUpdateById(paramEntity);
    }

    @ApiOperation(value = "删除")
    @ApiImplicitParam(name = "id", value = "主键ID", required = true, paramType = "path", dataType = "String")
    @DeleteMapping("/delete/{id}")
    public ResponseVO<Boolean> delete(@PathVariable String id) {
        return this.sonSingerService.deleteByIdLogic(id);
    }

    @ApiOperation(value = "批量删除（直接传入一个id数组）")
    @DeleteMapping("/delete-batch")
    public ResponseVO<Boolean> deleteBatch(@RequestBody List<String> idList) {
        return this.sonSingerService.deleteBatch(idList);
    }

    @ApiOperation(value = "列表查询（分页、条件查询）")
    @GetMapping("/pageList")
    public ResponseVO<IPage<SonSingerEntity>> list(SonSingerEntity entityParam, Query query) {
        return this.sonSingerService.myPageList(entityParam, query);
    }

    @ApiOperation(value = "详情")
    @ApiImplicitParam(name = "id", value = "主键ID", required = true, paramType = "path")
    @GetMapping("/detail/{id}")
    public ResponseVO<SonSingerEntity> detail(@PathVariable String id) {
        return this.sonSingerService.myGetById(id);
    }

}
